home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Type casting
- Date: Sat, 02 Mar 96 14:40:32 GMT
- Organization: none
- Message-ID: <825777632snz@genesis.demon.co.uk>
- References: <4gfnmi$gsc@calvin.risq.qc.ca> <4h5amm$dpv@umbc9.umbc.edu> <4h7oktINN433@anvil.ugrad.cs.ubc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4h7oktINN433@anvil.ugrad.cs.ubc.ca>
- c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
-
- >Incidentally, the only specific reference to undefined behavior in the context
- >of main() that I have been able to dig up in the Standard says that the exit
- >status of a program which doesn't provide a return value on exit from main() is
- >undefined. There is no discussion over T main() where T is not int, versus int
- >main().
-
- 5.1.2.2.1 describes the behaviour of main when it is defined as
-
- int main(void) { /*...*/ }
-
- or
-
- int main(int argc, char *argv[]) { /*...*/ }
-
- Some other forms can be shown to have the same behaviour as these from the
- rest of the standard (e.g. int main() or int main(int argc, char **argv) )
- but all of these forms return int. Nowhere does the standard define any
- behaviour for main returning a type other than int (or indeed most function
- declarations that do return int).
-
- 3.16 undefined behaviour
-
- "...
-
- If a ``shall'' or ``shall not'' requirement that appears outside of a
- constraint is violated, the behaviour is undefined. Undefined behaviour
- is otherwise indicated in this International Standard by the words
- ``undefined behaviour'' ## or by the omission of any explicit definition
- of behaviour. There is no difference in emphasis among these three; they
- all describe ``behaviour that is undefined.''"
-
- Note particularly everything after my ## mark. So void main() quite
- specifically invokes undefined behaviour according to the standard.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-